#define  _CRT_SECURE_NO_WARNINGS


#include<stdio.h>

int main()
{
    int a = 0, b = 0, c = 0, d = 0, sum = 0;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    sum = 0;
    while (a >= 2 && b >= 1 && d >= 2)
    {
        sum++;
        a -= 2;
        b--;
        d -= 2;
    }
    printf("%d\n", sum);
    sum = 0;
    while (a >= 1 && b >= 1 && c >= 1 && d >= 1)
    {
        sum++;
        a--;
        b--;
        c--;
        d--;
    }
    printf("%d\n", sum);
    sum = 0;
    while (c >= 2 && d >= 1)
    {
        sum++;
        c -= 2;
        d--;
    }
    printf("%d\n", sum);
    sum = 0;
    while (b >= 3)
    {
        sum++;
        b -= 3;
    }
    printf("%d\n", sum);
    sum = 0;
    while (a >= 1 && d >= 1)
    {
        sum++;
        a--;
        d--;
    }
    printf("%d\n", sum);

    return 0;
}